package com.worldcup.service.question.calculator;

import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 非程度题计算器
 * 答案相同得2分，两人都选“没有偏好”不得分，答案不同不得分
 * @author duwan.zq
 * @date 2019/03/08
 */
public class CommonCalculator implements AnswerCalculator{

    private final static BigDecimal SAME_SCORE = BigDecimal.valueOf(2);

    @Override
    public BigDecimal calHarmony(int score, BigDecimal harmonyWeight, int passiveScore) {
        if(score == passiveScore){
            return SAME_SCORE.multiply(harmonyWeight);
        }
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal calTopic(int score, BigDecimal topicWeight, int passiveScore) {
        if(score == passiveScore){
            return SAME_SCORE.multiply(topicWeight);
        }
        return BigDecimal.ZERO;
    }
}
